package com.example.shop.commodity.service;

import com.example.shop.base.BaseService;
import com.example.shop.commodity.entity.ShopCommodity;
import com.example.shop.commodity.dao.ShopCommodityDao;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

/**
 *  @author   hcj
 *  @date 2021-09-21 19:06:36
*/
@Service
public class ShopCommodityService extends BaseService<ShopCommodity, ShopCommodityDao>{
    public ShopCommodity get(String id){
        return dao.getById(id);
    }

    public PageInfo<ShopCommodity> search(ShopCommodity commodity){
        PageInfo<ShopCommodity> pageInfo = PageHelper.startPage(commodity.getPageNum(), commodity.getPageSize())
                .doSelectPageInfo(() -> dao.search(commodity));
        return pageInfo;
    }
}